package com.atguigu.study.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @auther zzyy
 * @create 2024-12-04 21:20
 */
@Aspect
@Component
@Slf4j
public class PayAspect
{
    @Before("execution(public void com.atguigu.study.service.impl.PayServiceImplV2.payV2*(..))")
    public void beforeNotify()
    {
        System.out.println("1-----@Before前置通知");
    }
    @After("execution(public void com.atguigu.study.service.impl.PayServiceImplV2.payV2*(..))")
    public void afterNotify()
    {
        System.out.println("2-----@After后置通知");
    }
    @AfterReturning("execution(public void com.atguigu.study.service.impl.PayServiceImplV2.payV2*(..))")
    public void afterReturningNotify()
    {
        System.out.println("3-----@AfterReturning返回通知");
    }
    @AfterThrowing("execution(public void com.atguigu.study.service.impl.PayServiceImplV2.payV2*(..))")
    public void afterThrowingNotify()
    {
        System.out.println("4-----@AfterThrowing异常通知");
    }

    @Around("execution(public void com.atguigu.study.service.impl.PayServiceImplV2.payV2*(..))")
    public Object aroundNotify(ProceedingJoinPoint proceedingJoinPoint) throws Throwable
    {
        Object retValue = null;

        System.out.println("5-----@Around环绕通知AAA---上半联");
        retValue = proceedingJoinPoint.proceed();
        System.out.println("6-----@Around环绕通知BBB---下半联");

        return retValue;
    }
}
